﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;
using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Grid;
using QuanLyKho.QuanLyChung;

namespace QuanLyKho.Control
{
    public partial class Quanly_Quatrinhsanxuat : UserControl
    {
        public Quanly_Quatrinhsanxuat()
        {
            InitializeComponent();
            LoadData();
        }

        public void LoadData()
        {
            DataTable data = DataAll.SelectAll("PhongMau_SanPham", "*", "Where TrangThai !=" + Convert.ToInt32(TrangThai.PhongMau_TaoMoi));
            gridQTsanxuat.DataSource = data;
            SetPropertiesGrid();
        }

        public void SetPropertiesGrid()
        {
            gvQTsanxuat.BestFitColumns();
            gvQTsanxuat.FocusRectStyle = DrawFocusRectStyle.RowFullFocus;
            gvQTsanxuat.OptionsBehavior.Editable = false;
            gvQTsanxuat.OptionsSelection.EnableAppearanceFocusedCell = false;
            gvQTsanxuat.OptionsSelection.MultiSelect = true;
            gvQTsanxuat.OptionsView.ShowGroupPanel = false;
            gvQTsanxuat.OptionsView.ColumnAutoWidth = false;
            gvQTsanxuat.OptionsView.ShowFooter = true;
            gvQTsanxuat.OptionsFind.AlwaysVisible = true;
            //gvQTsanxuat.Columns["IDLoaiHang"].Visible = false;
            SetPropertiesColumns();
        }

        public void SetPropertiesColumns()
        {
        }

        private void gvQTsanxuat_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.FieldName == "TrangThai")
            {
                e.DisplayText = Common.HienThiTrangThai(Convert.ToInt32(e.Value));
            }
        }

        private void gvQTsanxuat_DoubleClick(object sender, EventArgs e)
        {
            if (gvQTsanxuat.FocusedRowHandle >= 0)
            {
                HanhTrinh_Popup.SoChungTu = gvQTsanxuat.Columns["SoChungTu"].View.GetRowCellDisplayText(gvQTsanxuat.FocusedRowHandle, "SoChungTu");
                var lss = new HanhTrinh_Popup();
                lss.ShowDialog();
                LoadData();
                HanhTrinh_Popup.SoChungTu = string.Empty;
            }   
        }
    }
}
